package cn.itcast.controller;

import cn.itcast.domain.DingDan;
import cn.itcast.entity.PageResult;
import cn.itcast.entity.Result;
import cn.itcast.service.DingDanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * Created by leiylong on 2020/4/21
 */
@Controller
@RequestMapping("/dingdan")
public class DingdanController {

    @Autowired
    private DingDanService dingDanService;

    @GetMapping("/findDate")
    @ResponseBody
    public List<Map> findDate(String date) {
        return dingDanService.findDate(date);
    }

    @GetMapping("/findAll")
    @ResponseBody
    public List<DingDan> findAll() {
        List<DingDan> list = dingDanService.findAll();
        System.out.println(list);
        return list;
    }

    @GetMapping("/findPage")
    @ResponseBody
    public PageResult<DingDan> findPage(int page, int size) {
        return dingDanService.findPage(page, size);
    }

    @PostMapping("/addand")
    @ResponseBody
    public Result add(DingDan dingDan) {
        dingDanService.add(dingDan);
        return new Result();
    }

    @PostMapping("/update")
    @ResponseBody
    public Result update(DingDan dingDan) {
        dingDanService.update(dingDan);
        return new Result();
    }

    @PostMapping("/findList")
    @ResponseBody
    public List<DingDan> findList(Map<String, Object> searchMap) {
        return dingDanService.findList(searchMap);
    }

}
